﻿using System;
using System.Collections.Generic;
using System.Text;

using AIFSContentManagementSystem;
using AIFSContentManagementSystem.Articles;
using AIFSContentManagementSystem.Criteria;

using AIFSDataAccessLayer;

namespace AIFSCMSDataAccessLayer.RepositoryImpl
{
    public class DataAwareRepositoryMap : IDataAwareRepositoryMap
    {
        public DataAwareRepositoryMap(IDataExecutionContext DataExecutionContext)
        {
            this.dataExecutionContext = DataExecutionContext;
        }

        public T Get<T>() where T : IRepository
        {
            T repository = default(T);
            if (typeof(T) == typeof(IArticleRepository))
            {
                IArticleRepository artRepo = new ArticleRepository(this);
                repository = (T)artRepo;
            }
            else if (typeof(T) == typeof(ICriteriaRepository))
            {
                ICriteriaRepository critRepo = new CriteriaRepository(this);
                repository = (T)critRepo;
            }

            return repository;
        }

        IDataExecutionContext dataExecutionContext;
        public IDataExecutionContext DataExecutionContext
        {
            get
            {
                return dataExecutionContext;
            }
        }
    }
}
